home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 205_01 / wstype.c < prev    next >
Text File  |  1980-01-01  |  2KB  |  48 lines

  1. /*
  2. HEADER:                 CUG205.00;
  3. TITLE:                  WordStar TYPE Command;
  4. DATE:                   09/24/86;
  5. DESCRIPTION:
  6.   "TYPE command for WordStar document files on MS-DOS.";
  7. KEYWORDS:               Software tools, Text filters,wordstar type, text
  8.                         formatter;
  9. SYSTEM:                 MS-DOS;
  10. FILENAME:               WSTYPE.C;
  11. WARNINGS:
  12.   "The author claims copyrights and authorizes non-commercial use only.";
  13. AUTHORS:                 Michael M. Yokoyama;
  14. COMPILERS:              Microsoft;
  15. */
  16.  
  17. #include <stdio.h>
  18.  
  19. main(argc,argv)
  20. int argc;                       /* Number of command line words   */
  21. char *argv[];                   /* Pointers to command line words */
  22. {
  23.   int c;
  24.   FILE *in;             /* File used for input            */
  25.  
  26.   if (argc != 2) {      /* Check if enough arguments      */
  27.     fprintf(stderr,"WordStar TYPE command\n");
  28.     fprintf(stderr,"Usage:      wstype source\n");
  29.     exit(1);
  30.   }
  31.  
  32.   if ((in = fopen(argv[1],"r")) == NULL) {
  33.     fprintf(stderr,"wstype:  Can't open source file %s\n",argv[1]);     
  34.     exit(2);
  35.   }
  36.  
  37.   c = getc(in);
  38.   while (c != EOF) {    /* Continue until end of file     */
  39.     c = c &     127;    /* Strip most significant bit     */
  40.     if (((c >= ' ') && (c <= '~')) || (c == '\n')       || 
  41.       (c == '\r') || (c == '\t') || (c == '\f')) {
  42.       putchar(c);
  43.     }
  44.     c = getc(in);
  45.   }
  46.   fclose(in);
  47. }
  48.